<template>
  <!-- 首页导航栏 -->
  <div class="nav">
    <div class="nav-left">
      <div class="logo-wrapper"
           v-show="titleFlag"
           @click="goFront">
        <a class="logo"
           href="https://www.openharmony.cn/">
          <img class="logo-pic"
               src="../../assets/images/title.png" />
        </a>
      </div>

      <div class="menulist-wrapper"
           v-show="inputFlag">
        <div class="line">
        </div>
        <div class="nav-content">
          <el-menu :default-active="activeIndex"
                   class="el-menu-demo"
                   mode="horizontal"
                   router
                   @select="handleSelect">
            <el-menu-item class="main-txt"
                          @click="openDownload">下载</el-menu-item>
            <el-submenu index="2">
              <template slot="title"
                        class="main-txt">学习</template>
              <el-menu-item @click="openText">文档</el-menu-item>
              <el-menu-item index="/videoList"
                            :route="{ path: '/videoList', query: { id: 5 } }">学院</el-menu-item>
              <el-menu-item @click="openAllFeatures">开发样例</el-menu-item>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title"
                        class="main-txt">互动</template>
              <el-menu-item index="/newList"
                            :route="{ path: '/newList', query: { id: 3 } }">新闻</el-menu-item>
              <el-menu-item index="/blogList"
                            :route="{ path: '/blogList', query: { id: 2 } }">博客</el-menu-item>
              <el-menu-item index="/liveList"
                            :route="{ path: '/liveList', query: { id: 4 } }">直播</el-menu-item>
              <el-menu-item index="/activityList"
                            :route="{ path: '/activityList', query: { id: 1 } }">活动</el-menu-item>
              <el-menu-item @click="openMeeting">峰会</el-menu-item>
            </el-submenu>
            <el-submenu index="4">
              <template slot="title"
                        class="main-txt">社区</template>
              <el-menu-item @click="openManagement">行为守则</el-menu-item>
              <el-menu-item @click="openStrategy">贡献攻略</el-menu-item>
              <el-menu-item @click="openSig">找到兴趣组SIG</el-menu-item>
              <el-menu-item @click="openMail">订阅邮件列表</el-menu-item>
              <el-menu-item @click="openConduct">社区成长路径</el-menu-item>
              <el-menu-item @click="openPeople">项目管理委员会(PMC)</el-menu-item>
            </el-submenu>
            <el-submenu index="5">
              <template slot="title"
                        class="main-txt">兼容性认证</template>
              <el-menu-item @click="openCompatibility">申请认证</el-menu-item>
              <el-menu-item index="/armList"
                            :route="{ path: '/armList', query: { id: 6 } }">认证结果</el-menu-item>
            </el-submenu>
            <el-submenu index="7">
              <template slot="title"
                        class="main-txt">关于我们</template>
              <el-menu-item @click="openWork">工作委员会</el-menu-item>
              <el-menu-item @click="openTechnology">技术指导委员会</el-menu-item>
              <el-menu-item @click="openMore">捐赠人</el-menu-item>
            </el-submenu>
          </el-menu>
        </div>
      </div>
    </div>

    <div class="nav-right">
      <div class="nav-img"></div>
      <!-- <div class="nav-img"
           v-show="inputFlag"
           @click="searchText">
        <img src="../../assets/images/search.png" />
      </div> -->
      <div class="menuPhone"
           v-show="inputFlag">
        <img @click="openMenuPhone"
             src="../../assets/images/menuPh.png" />
      </div>
    </div>

    <div class="input-wrapper"
         v-show="!inputFlag">
      <input class="inputText"
             placeholder="请输入关键词"
             v-model="inputData" />
      <img @click="close"
           class="cancelImg"
           src="../../assets/images/close.png" />
    </div>
  </div>
</template>

<script>
export default {
  // props: ["activeIndex"],
  data () {
    return {
      activeIndex: "1",
      isPhone: false,
      titleFlag: true,
      inputFlag: true,
      inputData: "",
    };
  },
  created () {
    let phonewid = document.documentElement.clientWidth < 768;
    this.isPhone = phonewid;
  },
  methods: {
    handleSelect () { },
    //搜索框
    searchText: function () {
      this.inputFlag = false;
      if (this.isPhone) {
        this.titleFlag = false;
      }
    },
    //搜索框关闭
    close: function () {
      this.inputFlag = true;
      if (this.isPhone) {
        this.titleFlag = true;
      }
    },
    goFront () {
      this.$router.push("/mainPlay");
    },
    inputContent: function () { },
    //手机端菜单
    openMenuPhone: function () {
      this.$router.push("/menuBar");
      // this.menuPhone = true;
    },
    changehandleNav: function () { },
    openDownload () {
      window.open("https://www.openharmony.cn/download/");
    },
    openAllFeatures () {
      window.location.href = "http://139.159.252.23:9067/mainPlay/content/mainText/allFeatures";
      // window.open("http://139.159.252.23:9067/mainPlay/content/mainText/allFeatures");
    },
    openText () {
      window.open("https://www.openharmony.cn/documents/");
    },
    openMeeting () {
      window.open("https://www.openharmony.cn/activities/hdc2021/");
    },
    openManagement () {
      window.open("https://www.openharmony.cn/projects_management/");
    },
    openStrategy () {
      window.open("https://www.openharmony.cn/community/contribution/");
    },
    openSig () {
      window.open("https://www.openharmony.cn/sig_management/");
    },
    openMail () {
      window.open("https://www.openharmony.cn/community/maillist/");
    },
    openConduct () {
      window.open("https://www.openharmony.cn/community/introduction/");
    },
    openPeople () {
      window.open("https://www.openharmony.cn/community/pmc/");
    },
    openCompatibility () {
      window.open("https://www.openharmony.cn/old/#/Compatibility_test");
    },
    openWork () {
      window.open("https://www.openharmony.cn/projects_management/#_4-2-工作委员会");
    },
    openTechnology () {
      window.open("https://www.openharmony.cn/projects_management/#_4-5-技术指导委员会-tsc");
    },
    openMore () {
      window.open("https://www.openharmony.cn/members/");
    },
  },
};
</script>

<style lang="less" scoped>
@media screen and (min-width: 1032px) {
  .base {
    width: 1032px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
  .nav {
    height: 72px;
    padding: 0 36px;
    display: flex;
    justify-content: space-between;
    .menuPhone {
      display: none;
    }
    .nav-left {
      display: flex;
      .logo-wrapper {
        height: 72px;
        line-height: 72px;
        text-align: center;
        cursor: pointer;
        .logo-pic {
          width: 152px;
          height: 22px;
        }
      }
      .menulist-wrapper {
        display: flex;
        .line {
          width: 1px;
          height: 24px;
          margin: 24px 32px 0 48px;
          background: rgba(0, 0, 0, 0.06);
        }
        .nav-content {
          ::v-deep .el-menu-demo {
            border-bottom: 0;
          }
          ::v-deep .el-menu--horizontal > .el-submenu .el-submenu__title {
            border-bottom: 0;
            height: 72px;
            line-height: 72px;
            font-size: 16px;
            font-family: HarmonyOS_Sans_SC;
            color: rgba(0, 0, 0, 0.85);
          }
          ::v-deep .el-menu-item {
            height: 72px;
            line-height: 72px;
            font-size: 16px;
            font-family: HarmonyOS_Sans_SC;
            color: rgba(0, 0, 0, 0.85);
          }
          ::v-deep .el-menu--horizontal > .el-submenu .el-submenu__icon-arrow {
            display: none;
          }
        }
      }
    }
    .nav-right {
      display: flex;
      .nav-img {
        height: 72px;
        line-height: 72px;
        text-align: center;
        padding-right: 16px;
      }
    }
  }

  /deep/.el-submenu__title {
    margin-bottom: -8px;
  }
  .input-wrapper {
    width: 680px;
    height: 48px;
    margin: 12px 0;
    position: relative;
    border-radius: 8px;
    .inputText {
      width: 680px;
      height: 48px;
      background: #f9f9f9;
      text-indent: 10px;
      caret-color: #81bd0a;
    }
    .cancelImg {
      position: absolute;
      top: 15px;
      bottom: 17px;
      right: 24px;
      cursor: pointer;
    }
  }
}
@media screen and (min-width: 768px) and (max-width: 1032px) {
  .base {
    width: 768px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
  .nav {
    display: flex;
    height: 56px;
    justify-content: space-between;
    background-color: #fff;
    .nav-left {
      .logo-wrapper {
        height: 56px;
        line-height: 56px;
        text-align: center;
        cursor: pointer;
        .logo-pic {
          width: 152px;
          height: 22px;
        }
      }
      .menulist-wrapper {
        width: 50%;
        display: flex;
        justify-content: flex-end;
        display: flex;
        .nav-content {
          display: none;
        }
        .line {
          display: none;
        }
      }
    }
    .nav-right {
      display: flex;
      .nav-img {
        height: 56px;
        line-height: 56px;
        text-align: center;
        margin-right: 16px;
        cursor: pointer;
      }
      .menuPhone {
        display: block;
        height: 56px;
        line-height: 56px;
        text-align: center;
        margin-right: 16px;
        cursor: pointer;
      }
    }
  }
}
@media screen and (max-width: 768px) {
  .base {
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
  .nav {
    .base;
    display: flex;
    height: 46px;
    justify-content: space-between;
    background: #ffffff;
    box-shadow: 0px 6px 10px 0px rgba(0, 0, 0, 0.06);
    .nav-left {
      .logo-wrapper {
        margin-left: 12px;
        height: 46px;
        line-height: 46px;
        text-align: center;
        cursor: pointer;
        .logo-pic {
          width: 152px;
          height: 22px;
        }
      }
      .menulist-wrapper {
        display: flex;
        .nav-content {
          display: none;
        }
        .line {
          display: none;
        }
        .menuPhone {
          display: block;
          height: 46px;
          line-height: 46px;
          text-align: center;
          margin-right: 16px;
        }
        .nav-img {
          height: 46px;
          line-height: 46px;
          text-align: center;
          margin-right: 16px;
          cursor: pointer;
        }
      }
    }
    .nav-right {
      display: flex;
      align-items: center;
      .nav-img {
        height: 56px;
        line-height: 56px;
        text-align: center;
        margin-right: 16px;
        cursor: pointer;
      }
      .menuPhone {
        display: block;
        height: 56px;
        line-height: 56px;
        text-align: center;
        margin-right: 16px;
        cursor: pointer;
      }
    }

    .input-wrapper {
      width: 100%;
      position: relative;
      height: 46px;
      line-height: 46px;
      .inputText {
        width: 100%;
        height: 46px;
        background: #f9f9f9;
        text-indent: 10px;
        caret-color: #81bd0a;
      }
      .cancelImg {
        position: absolute;
        top: 15px;
        bottom: 17px;
        right: 24px;
        cursor: pointer;
      }
    }
  }
}
</style>
